package cn.kgm.admin.api.factory;

import cn.kgm.admin.api.RemoteLogService;
import cn.kgm.core.http.response.R;
import cn.kgm.security.entity.SysLogininfor;
import cn.kgm.security.entity.SysOperLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 *
 * @kapi #技术改变自己#
 * @AUTHOR: ruoyi
 * @EMAIL: yolo.jk@qq.com
 * @DATE: 2023/4/25 11:29 周二
 */
@Slf4j
@Component
public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogService>
{
    @Override
    public RemoteLogService create(Throwable throwable)
    {
        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new RemoteLogService()
        {
            @Override
            public R<Boolean> saveLog(SysOperLog sysOperLog, String source)
            {
                return R.fail();
            }

            @Override
            public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
            {
                return R.fail();
            }
        };

    }
}
